package notification.net;
import notification.handler.HandlerNotification;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
  

  public class ServerHandler extends SimpleChannelUpstreamHandler {
	  private static HandlerNotification work;	  
	  
	  public ServerHandler(HandlerNotification HN){
		  work=HN;
	  }
   
      public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
    	MessageWialon rec=(MessageWialon) e.getMessage();
    	work.get(rec.IDcontroller).setMessage(rec);
    	work.getSem().release();
      }
  

      public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
    	  System.out.println(e);
          e.getChannel().close();
      }
  }
